<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="com.tjsinfo.tjsoa.common.PaginationSupport"%>
<%@ page import="com.tjsinfo.tjsoa.common.DealString"%>
<%@page import="com.tjsinfo.tjsoa.vote.vo.TVoteConformation;"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	DealString ds = new DealString();
	PaginationSupport paginationSupport = (PaginationSupport) request.getAttribute("paginationSupport");
	List<TVoteConformation> conformationLists = paginationSupport.getItems();
	String pageNoStr = request.getParameter("pageNo");
	if (pageNoStr == null)pageNoStr = "0";
	Integer pageNo = Integer.valueOf(pageNoStr);
	
	TVoteConformation conformation = (TVoteConformation) request.getAttribute("conformation");
	String title = conformation.getName();
	if (title.length() > 30)title = ds.substring(title, 30);
	
	String headId = (String) request.getAttribute("headId");
	String status = (String) request.getAttribute("status");
	String parentId = (String) request.getAttribute("parentId");
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>粮油集团办公自动化协作平台</title>
		<link href="<%=basePath%>style/txlz7.css" rel="stylesheet" type="text/css" />
		<link href="<%=basePath%>ajaxFramework/ext-2.1/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/adapter/ext/ext-base.js"></script>
		<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/ext-all.js"></script>
		<script type="text/javascript" src="<%=basePath%>ajaxFramework/ext-2.1/source/locale/ext-lang-zh_CN.js"></script>
		<script type="text/javascript" src="<%=basePath %>ajaxFramework/jQuery/jquery.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/common/global/validator.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/common/global/pageControl.js"></script>
		<script type="text/javascript" src="<%=basePath %>js/common/system/selectusercheck.js"></script>
		<style>
			body {
				font-size: 11px;
				font-family: Verdana, Arial, Helvetica, sans-serif;
			}
			a {
				color: #000;
				text-decoration: none;
			}
			.img {
				border: 0px;
			}
			.black_overlays {
				display: none;
				position: absolute;
				top: 0%;
				left: 0%;
				width: 100%;
				height: 900px;
				background-color: gray;
				z-index: 1001;
				-moz-opacity: 0.8;
				opacity: .80;
				filter: alpha(opacity =   80);
			}
			.list_01 {
				display: none;
				position: absolute;
				top: 25%;
				left: 10%;
				width: 500px;
				height: 100px;
				border: 16px solid #FFF;
				border-bottom: none;
				background-color: white;
				z-index: 1002;
				overflow: auto;
			}
			.list_01 li {
				width: 117px;
				float: left
			}
			.tree {
				display: none;
				position: absolute;
				top: 25%;
				left: 35%;
				width: 255px;
				height: 235px;
				border: 16px solid #FFF;
				border-bottom: none;
				background-color: white;
				z-index: 1002;
				overflow: auto;
			}
		</style>
		<script type="text/javascript">
			function submitpages(value){
				if(value==-1){
					alert("请重新选择页码!");
					return ;
				}
				var urls=location.href;
				if(urls.indexOf('pageNo=')==-1){
					if(urls.indexOf('?')==-1){//wucan
						window.location.href=urls+'?pageNo='+value;
					}else{
						window.location.href=urls+'&pageNo='+value;
					}
				}else{
					urls=urls.substring(0,urls.indexOf('pageNo=')+7)+value;
					window.location.href=urls;
				}
			}
			
			$(function(){
				$.ajaxSetup({
				  async: false
				  }); 
				$(".s09 >a").attr("href","javascript:ko()");
				$(".s10 >a").attr("href","javascript:cancel()");
			});		
			
			function del(conformationId,parentId,name){
                Ext.MessageBox.confirm("提示信息","是否删除行: "+name+" ?",function(btn){
  		           if(btn == 'yes'){
  			          msg();
			          window.location.href='<%=basePath%>tjsinfo/tjsoa/vote/conformationDel.do?conformationId='+conformationId+'&parentId='+parentId+'&status=<%=status%>&headId=<%=headId%>';
			          return;	
  		           }
                });
			}				
		</script>
	</head>
	<body>
		<div id="rightindex" style="height:97%">
			<div id="tab"  style="width:99%">
				<!--导航开始处-->
				<div id="indextit">
					<table width="100%" border="0" cellspacing="0" cellpadding="0">
						<tr>
							<td width="30" style="padding-bottom: 4px;">
								<img src="<%=basePath%>images/1234.gif" />
							</td>
							<td valign="middle"><%=title%></td>
						</tr>
					</table>
				</div>
				<!--这里开始是显示、隐藏的内容-->
				<div id="index_main">
					<div class="draft_list">
						<ul>
							<%
								String name = "";
								int i = 0;
								for (TVoteConformation conformationList : conformationLists) {
									i++;
									if (i % 7 == 0)out.print("</ul><ul>");
									name = conformationList.getName();
									if (name.length() > 30)name = ds.substring(name, 30);
							%>
							<li>
								<%=name%>
								<%
									if ("0".equals(status)) {
								%>
								<span> 
								    <a onclick="del('<%=conformationList.getId()%>','<%=conformationList.getParentId()%>','<%=conformationList.getName()%>')" style="cursor: hand"><font color="blue">删除</font></a>
								</span>
								<%
									}
								%>
							</li>
							<%
								}
							%>
						</ul>
					</div>
					<div class="page">
						共<%=paginationSupport.getTotalCount()%>条,共<%=paginationSupport.getPageCount()%>页&nbsp;&nbsp;
						当前为第<%=pageNo + 1%>页&nbsp;&nbsp;
						<%
							if (paginationSupport.getStartIndex() > 1) {
						%>
						<a onclick="submitpages('<%=pageNo - 1%>')" style="cursor: hand">上一页</a>
						<%
							}
						%>
						<%
							if (paginationSupport.getStartIndex()
									+ paginationSupport.getPageSize() < paginationSupport
									.getTotalCount()) {
						%>
						<a onclick="submitpages('<%=pageNo + 1%>')" style="cursor: hand">下一页</a>
						<%
							}
						%>
						&nbsp;&nbsp; 跳转到

						<select name="selectPage" id="selectPage"
							onchange="submitpages(this.value)">
							<option value="0">
								--跳转--
							</option>
							<%
								for (int pi = 0; pi < paginationSupport.getPageCount(); pi++) {
							%>
							<option value="<%=pi%>"><%=pi + 1%></option>
							<%
								}
							%>
						</select>
						页

					</div>
					<table>
						<tr>
							<%
								if ("0".equals(status)) {
							%>
							<td>
								<a onclick="document.getElementById('lightRole').style.display='block';document.getElementById('fade').style.display='block'" style="cursor: hand"><font color="blue">创建子行</font></a>
							</td>
							<form name="form1" action="<%=basePath%>tjsinfo/tjsoa/vote/conformationAdd.do?headId=<%=headId%>&status=<%=status%>&parentId=<%=parentId%>" method="post">
								<div id="lightRole" class="list_01">
									行名称：&nbsp;&nbsp;&nbsp;
									<input id="name" type="text" name="name" size="60" />
									<br />
									排列序号：

									<input id="orderId" type="text" name="orderId" size="20" />
									<hr />
									<div align="center">
										<ul>
											<li class="s09">
												<a href="#"><img src="<%=basePath%>images/sub_btn.gif" width="72" height="17" /></a>
											</li>
											<li class="s10">
												<a href="#"><img src="<%=basePath%>images/cancel.gif" width="72" height="17" /></a>
											</li>
										</ul>
									</div>
								</div>
								<script>
									function ko(){
										if(isnull("input[name='name']","行不能为空！")
										&&isnull("input[name='orderId']","排列序号不能为空！"))
										{
										    if(mustisnumber("input[name='orderId']","排列序号必须为数字！")){
												//var start = valName();
												var start = true;
												if(start == true)
												{
												   document.getElementById('lightRole').style.display='none';
												   document.getElementById('fade').style.display='none';	
												   msg();
												   form1.submit();
												   //$("form[name='form1']").submit();
												}
											}
										}	
									}
							        
									function cancel(){
										document.getElementById('lightRole').style.display='none';
										document.getElementById('fade').style.display='none';
									    document.getElementById('name').value='';
									    document.getElementById('orderId').value='';
									}
								</script>
								<div id="fade" class="black_overlays"></div>
							</form>
							<%
								}
							%>
							<td>
								&nbsp;&nbsp;&nbsp;&nbsp;
								<a href="<%=basePath%>tjsinfo/tjsoa/vote/conformationList.do?headId=<%=headId%>&status=<%=status%>&parentId=0"><font color="blue">返回</font></a>
							</td>
						</tr>
					</table>
					<div class="clear"></div>
				</div>
			</div>
		</div>
	</body>
</html>